﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.SessionState;
using System.IO;

namespace iSun.WebApp
{
    public class FlashHandler : IHttpHandler, IRequiresSessionState
    {
        /// <summary>
        /// 您将需要在您网站的 web.config 文件中配置此处理程序，
        /// 并向 IIS 注册此处理程序，然后才能进行使用。有关详细信息，
        /// 请参见下面的链接: http://go.microsoft.com/?linkid=8101007
        /// </summary>
        #region IHttpHandler Members

        public bool IsReusable
        {
            // 如果无法为其他请求重用托管处理程序，则返回 false。
            // 如果按请求保留某些状态信息，则通常这将为 false。
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            //文件上传存储路径
            string postid = context.Request.QueryString["postid"];
            string uploadPath = context.Server.MapPath(context.Request.ApplicationPath + "/Upload");

            for (int i = 0; i < context.Request.Files.Count; i++)
            {
                HttpPostedFile uploadFile = context.Request.Files[i];
                if (uploadFile.ContentLength > 0)
                {
                    uploadFile.SaveAs(Path.Combine(uploadPath, uploadFile.FileName));
                }
            }

            HttpContext.Current.Response.Write(" ");
        }

        #endregion
    }
}
